<template>
  <div class="children">
    <el-dialog title="审核" :visible.sync="$parent.openaudit" width="70%">
      <div class="center_dialog">
        <el-divider>申请信息</el-divider>
        <el-descriptions :colon="false" title="" direction="vertical" :column="3" border>
          <el-descriptions-item label="申请时间">{{ allocation.applicationTime || '-' }}</el-descriptions-item>
          <el-descriptions-item label="申请人">{{ allocation.applicantName || '-' }}</el-descriptions-item>
          <el-descriptions-item label="申请原因">{{ allocation.reason || '-' }}</el-descriptions-item>
        </el-descriptions>
        <el-divider>相关附件</el-divider>
        <el-link :disabled="!allocation.file" type="primary" icon="el-icon-document" :href="allocation.file"
          target="_blank">附件资料</el-link>
        <el-divider>调拨列表</el-divider>
        <el-table :data="allocation.allocationEquipmentAccountVos">
          <el-table-column prop="eaPartInfoVo.equipmentNum" label="设备编号" width="120"></el-table-column>
          <el-table-column prop="eaPartInfoVo.equipmentName" label="设备名称" width="120"></el-table-column>
          <el-table-column prop="eaPartInfoVo.model" label="规格型号"></el-table-column>
          <el-table-column prop="oldDeptName" label="调出部门"></el-table-column>
          <el-table-column prop="oldPlaceName" label="调出位置"></el-table-column>
          <el-table-column prop="oldHeadName" label="原负责人"></el-table-column>
          <el-table-column prop="newDeptName" label="调入部门"></el-table-column>
          <el-table-column prop="newPlaceName" label="调入位置"></el-table-column>
          <el-table-column prop="newHeadName" label="新负责人"></el-table-column>
        </el-table>
        <el-divider>审核信息</el-divider>
        <el-input type="textarea" v-model="form.view" placeholder="请填写审核意见" :rows="4"></el-input>
      </div>
      <div align="center" slot="footer" class="dialog-footer">
        <el-button type="success" @click="submitAudit('2')">通过</el-button>
        <el-button type="danger" @click="submitAudit('3')">驳回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getallocation, putAuditAllocation } from '@/api/management/management.js'
export default {
  props: ['rowObj'],
  data () {
    return {
      form: {
        "auditId": undefined, //审核信息ID
        "applicationId": undefined, //调拨ID
        "status": undefined, //状态（2已通过 3已驳回）
        "view": undefined //审核意见
      },
      auditData: [],
      islength: true,
      allocation: {},
      gridData: []
    }
  },
  created () {
    this.getlist()
  },
  methods: {
    /**
     * 初始化
     */
    getlist () {
      getallocation(this.rowObj.allocationId).then(res => {//详情接口
        this.allocation = res.data
      })
    },
    /**
     * 提交
     */
    submitAudit (condition) {
      if ((!this.form.view) && condition === '3') return this.$message.error('驳回时审核意见不可为空')

      let params = {
        auditId: this.rowObj.audit && this.rowObj.audit.auditId,
        applicationId: this.rowObj.allocationId,
        status: condition,
        view: this.form.view
      }
      putAuditAllocation(params).then(res => {
        this.$parent.openaudit = false
        this.$message.success(res.msg)
        this.$parent.getList()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.center_dialog {
  // text-align: center;
  width: 80%;
  // padding: 0 10% 0 10%;
  box-sizing: border-box;
  margin: 0px auto;
}

.accep_flex {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>